<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
	<script src="lib/axios.min.js"></script>
</head>
<body>
	<div>欢迎<span style="color:red;"></span>的到来！<button>退出</button></div>
	<div id="app">
	
	</div>
</body>
<script>
	if(localStorage.getItem("username")){
		axios.get("/info/"+localStorage.getItem("username")).then(value=>{
			if(value.data.ok === 1){
				document.querySelector("span").innerText = value.data.info.username;
				document.querySelector("#app").innerHTML = (`
					<p>用户名：${value.data.info.username}</p>
					<p>性别：${value.data.info.sex}</p>
					<p>爱好：${value.data.info.hobby}</p>
					<p>是否已婚：${value.data.info.isJieHun?"已婚":"未婚"}</p>
				`)
			}else{
				alert(value.data.msg);
				location.href="/login.html";
			}
		})
		
		document.querySelector("button").onclick = function(){
			localStorage.clear();
			location.href="/login.html";
		}
	}else{
		alert("您无权访问");
		location.href="/login.html";
	}
</script>
</html>